<script language="javascript">
function btnLogin_onclick(){
	if(test_empty(document.frmLogin.txtUid.value)){
		alert(mustInput_Uid);document.frmLogin.txtUid.focus();return false;
	}
	if(test_empty(document.frmLogin.txtPwd.value)){
		alert(mustInput_Pwd);document.frmLogin.txtPwd.focus();return false;
	}
	return true;
}
</script>
<? $errMsg ='';
?>
<?
if (isset($_POST['btnLogin'])){
	$uid = isset($_POST['txtUid']) ? trim($_POST['txtUid']) : "";
	$pwd = isset($_POST['txtPwd']) ? trim($_POST['txtPwd']) : "";
	
	if(!isset($_SESSION['member']) || $_SESSION['member']==''){
		$result = mysql_query("select * from tbl_member where uid='".$uid."'",$conn);
		$rows = mysql_num_rows($result);
		if($rows<1){
			$errMsg = 'Username wrong !';
		}else{
			$row = mysql_fetch_array($result);
			if($pwd != $row['pwd']){
				$errMsg ='Password wrong !';
			}else{
				$flagLogin = true;
			}
		}
	}
}
if($flagLogin){
	$_SESSION['member'] = isset($_SESSION['member'])?$_SESSION['member']:$uid;
	}
?>

<form name="frmLogin" method="POST" action="./">
	                <input type="hidden" name="frame" value="login">
					<input type="hidden" name="btnLogin">
<table width="100%" border="0" cellspacing="3" cellpadding="0">
                  <tr>
                    <td class="td1">User:</td>
                  </tr>
                  <tr>
                    <td><input name="txtUid" type="text" class="style34" /></td>
                  </tr>
                  <tr>
                    <td class="td1">M&#7853;t kh&#7849;u: </td>
                  </tr>
                  <tr>
                    <td><input name="txtPwd" type="password" class="style34" /></td>
                  </tr>
                  <tr>
                    <td class="td1"><input type="checkbox" name="checkbox" value="checkbox" />
                      T&#7921; &#273;&#7897;ng &#273;&#259;ng nh&#7853;p?</td>
                  </tr>
                  <tr>
                    <td><input name="btnLogin" type="submit" class="button1" value="Đăng nhập" onmouseover="this.className='button2'" onmouseout="this.className='button1'" onClick="return btnLogin_onclick()"/></td>
                  </tr>
                  <tr>
                    <td class="td1"><img src="images/icon_8.gif" width="12" height="9" /> <a href="./?frame=registry" class="link">&#272;&#259;ng k&yacute; th&agrave;nh vi&ecirc;n m&#7899;i!</a></td>
                  </tr>
                  <tr>
                    <td class="td1"><img src="images/icon_8.gif" width="12" height="9" /> <a href="./?frame=forgotpass" class="link">Qu&ecirc;n m&#7853;t kh&#7849;u?</a></td>
                  </tr>
                </table>
</form>